#include<bits/stdc++.h>
using namespace std;
struct Meet{
    int begin;
    int end;
}meets[1000];
bool cmp(Meet a,Meet b){
    return a.end<b.end;
}
int n;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>meets[i].begin>>meets[i].end;
    }

    sort(meets,meets+n,cmp);
    int tot=0;
    int begin=0;
    for(int i=0;i<n;i++){
        if(meets[i].begin>=begin){
            tot++;
            begin=meets[i].end;
        }
    }
    cout<<tot<<endl;

    return 0;
}
